import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
results = pd.read_csv("results.csv", engine="python")
print(results.dtypes)
display(results)
date object home_team object away_team object home_score int64 away_score int64 tournament object city object country object neutral bool dtype: object
| date | home_team | away_team | home_score | away_score | tournament | city | country | neutral | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 1872-11-30 | Scotland | England | 0 | 0 | Friendly | Glasgow | Scotland | False |
| 1 | 1873-03-08 | England | Scotland | 4 | 2 | Friendly | London | England | False |
| 2 | 1874-03-07 | Scotland | England | 2 | 1 | Friendly | Glasgow | Scotland | False |
| 3 | 1875-03-06 | England | Scotland | 2 | 2 | Friendly | London | England | False |
| 4 | 1876-03-04 | Scotland | England | 3 | 0 | Friendly | Glasgow | Scotland | False |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 42423 | 2021-07-06 | Trinidad and Tobago | French Guiana | 1 | 1 | Gold Cup qualification | Fort Lauderdale | United States | True |
| 42424 | 2021-07-07 | England | Denmark | 2 | 1 | UEFA Euro | London | England | False |
| 42425 | 2021-07-09 | Peru | Colombia | 2 | 3 | Copa América | Brasília | Brazil | True |
| 42426 | 2021-07-10 | Brazil | Argentina | 0 | 1 | Copa América | Rio de Janeiro | Brazil | False |
| 42427 | 2021-07-11 | England | Italy | 1 | 1 | UEFA Euro | London | England | False |
42428 rows × 9 columns
conditions=[ results['home_score']>results['away_score'],results['home_score']==results['away_score'],results['home_score']<results['away_score']]
match_result=[ "home_win", 'draw', 'away_win']
results["result"] = np.select(conditions, match_result)
results
| date | home_team | away_team | home_score | away_score | tournament | city | country | neutral | result | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1872-11-30 | Scotland | England | 0 | 0 | Friendly | Glasgow | Scotland | False | draw |
| 1 | 1873-03-08 | England | Scotland | 4 | 2 | Friendly | London | England | False | home_win |
| 2 | 1874-03-07 | Scotland | England | 2 | 1 | Friendly | Glasgow | Scotland | False | home_win |
| 3 | 1875-03-06 | England | Scotland | 2 | 2 | Friendly | London | England | False | draw |
| 4 | 1876-03-04 | Scotland | England | 3 | 0 | Friendly | Glasgow | Scotland | False | home_win |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 42423 | 2021-07-06 | Trinidad and Tobago | French Guiana | 1 | 1 | Gold Cup qualification | Fort Lauderdale | United States | True | draw |
| 42424 | 2021-07-07 | England | Denmark | 2 | 1 | UEFA Euro | London | England | False | home_win |
| 42425 | 2021-07-09 | Peru | Colombia | 2 | 3 | Copa América | Brasília | Brazil | True | away_win |
| 42426 | 2021-07-10 | Brazil | Argentina | 0 | 1 | Copa América | Rio de Janeiro | Brazil | False | away_win |
| 42427 | 2021-07-11 | England | Italy | 1 | 1 | UEFA Euro | London | England | False | draw |
42428 rows × 10 columns
def home_away_draws(df): #returns number of home wins, away wins, draws and total games played
home_wins=len(df[df.away_score<df.home_score])
away_wins=len(df[df.away_score>df.home_score])
draws=len(df[df.away_score==df.home_score])
total_games_played=home_wins+away_wins+draws
avg_home=df['home_score'].mean()
avg_away=df['away_score'].mean()
return home_wins,away_wins,draws,total_games_played,avg_home,avg_away
def draw_pie(title, pie): #draw pie chart for draws team
labels = ['Home wins', 'Away wins', 'Draws']
sizes = pie
colors = ['#39375b','#745c97','#d597ce']
plt.figure(figsize=(15,10))
fig1, ax1 = plt.subplots()
plt.title(title)
patches, texts, autotexts = ax1.pie(sizes, colors = colors, labels=labels, autopct='%1.1f%%', startangle=90)
for text in texts:
text.set_color('grey')
for autotext in autotexts:
autotext.set_color('white')
ax1.axis('equal')
plt.tight_layout()
plt.show()
major_tournaments = ['FIFA World Cup','Confederations Cup','Oceania Nations Cup','CCCF Championship','AFC Asian Cup','Copa América','Gold Cup','UEFA Euro','NAFU Championship','African Cup of Nations']
major=results.loc[results['tournament'].isin(major_tournaments) , :]
#All games including matches that were played in nuetral grounds
m_home_wins, m_away_wins, m_draws, m_total_games_played, m_home_score_avg, m_away_score_avg = home_away_draws(major)
print(f'Away wins: {m_away_wins}')
print(f'Home wins: {m_home_wins}')
print(f'Draws: {m_draws}')
print(f'Home side goal per game: {m_home_score_avg}')
print(f'Away side goal per game: {m_away_score_avg}')
m_home_win_percent=m_home_wins/m_total_games_played
m_away_win_percent=m_away_wins/m_total_games_played
m_draw_percent=m_draws/m_total_games_played
print(m_home_win_percent)
print(m_away_win_percent)
print(m_draw_percent)
draw_pie("Home wins vs Away Wins in Neutral Games", [m_home_win_percent,m_away_win_percent,m_draw_percent])
Away wins: 1141 Home wins: 1832 Draws: 863 Home side goal per game: 1.6715328467153285 Away side goal per game: 1.2082898852971846 0.47758081334723673 0.29744525547445255 0.22497393117831074
<Figure size 1080x720 with 0 Axes>
#Matches that were played in either home or away grounds (non-neutral games)
major_nn = major[major['neutral']==False]
nn_m_home_wins, nn_m_away_wins, nn_m_draws, nn_m_total_games_played, nn_m_home_score_avg, nn_m_away_score_avg = home_away_draws(major_nn)
print(f'Away wins: {nn_m_away_wins}')
print(f'Home wins: {nn_m_home_wins}')
print(f'Draws: {nn_m_draws}')
print(f'Home side goal per game: {nn_m_home_score_avg}')
print(f'Away side goal per game: {nn_m_away_score_avg}')
nn_m_home_win_percent=nn_m_home_wins/nn_m_total_games_played
nn_m_away_win_percent=nn_m_away_wins/nn_m_total_games_played
nn_m_draw_percent=nn_m_draws/nn_m_total_games_played
print(nn_m_home_win_percent)
print(nn_m_away_win_percent)
print(nn_m_draw_percent)
draw_pie("Home wins vs Away Wins in Non-Neutral Games",[nn_m_home_win_percent,nn_m_away_win_percent,nn_m_draw_percent])
Away wins: 182 Home wins: 568 Draws: 198 Home side goal per game: 1.9841772151898733 Away side goal per game: 0.9483122362869199 0.5991561181434599 0.19198312236286919 0.2088607594936709
<Figure size 1080x720 with 0 Axes>
#Goals by tournaments
avg_goal=major.pivot_table(['home_score','away_score'],columns='tournament',aggfunc=np.sum)
avg_goal.loc['total']=avg_goal.sum(axis=0)
avg_goal=avg_goal.T
avg_goal
| away_score | home_score | total | |
|---|---|---|---|
| tournament | |||
| AFC Asian Cup | 429 | 558 | 987 |
| African Cup of Nations | 723 | 948 | 1671 |
| CCCF Championship | 193 | 356 | 549 |
| Confederations Cup | 193 | 230 | 423 |
| Copa América | 1077 | 1594 | 2671 |
| FIFA World Cup | 1136 | 1412 | 2548 |
| Gold Cup | 336 | 567 | 903 |
| NAFU Championship | 11 | 17 | 28 |
| Oceania Nations Cup | 156 | 282 | 438 |
| UEFA Euro | 381 | 448 | 829 |
#Average Goals per Tournament
count=major['tournament'].value_counts()
count=count.sort_index()
avg_goal['count']=count
avg_goal['avg']=avg_goal['total']/avg_goal['count']
avg_goal
| away_score | home_score | total | count | avg | |
|---|---|---|---|---|---|
| tournament | |||||
| AFC Asian Cup | 429 | 558 | 987 | 370 | 2.667568 |
| African Cup of Nations | 723 | 948 | 1671 | 690 | 2.421739 |
| CCCF Championship | 193 | 356 | 549 | 123 | 4.463415 |
| Confederations Cup | 193 | 230 | 423 | 140 | 3.021429 |
| Copa América | 1077 | 1594 | 2671 | 841 | 3.175981 |
| FIFA World Cup | 1136 | 1412 | 2548 | 900 | 2.831111 |
| Gold Cup | 336 | 567 | 903 | 327 | 2.761468 |
| NAFU Championship | 11 | 17 | 28 | 7 | 4.000000 |
| Oceania Nations Cup | 156 | 282 | 438 | 101 | 4.336634 |
| UEFA Euro | 381 | 448 | 829 | 337 | 2.459941 |
#Above table visualized
plt.figure(figsize=(20,5))
plt.title("Average Goal per Game Based on Tournament")
sns.set_style("darkgrid")
sns.barplot(x=avg_goal.index,y=avg_goal['avg'],color='#d597ce');
#Host country
matches_hosted=pd.DataFrame()
matches_hosted['counts']=major['country'].value_counts()
matches_hosted['country']=major['country'].value_counts().index
matches_hosted=matches_hosted.reset_index()
matches_hosted.drop(columns=['index'],inplace=True)
matches_hosted
| counts | country | |
|---|---|---|
| 0 | 393 | United States |
| 1 | 239 | Brazil |
| 2 | 168 | France |
| 3 | 160 | Argentina |
| 4 | 155 | Chile |
| ... | ... | ... |
| 78 | 4 | Hungary |
| 79 | 3 | United Arab Republic |
| 80 | 3 | Canada |
| 81 | 3 | Azerbaijan |
| 82 | 1 | Wales |
83 rows × 2 columns
#Conversion of counrtry names to ISO-3661-alpha-3 format for plotly
import pycountry
input_countries = matches_hosted['country']
change={"Netherlands Antilles":"Aruba","United Arab Republic":"Egypt","South Korea":"Korea, Republic of","Bolivia":"Bolivia, Plurinational State of","England":"United Kingdom","Iran":"Iran, Islamic Republic of","Venezuela":"Venezuela, Bolivarian Republic of","Yugoslavia":"Serbia","Ivory Coast":"Côte d'Ivoire","China PR":"Taiwan, Province of China","Vietnam":"Viet Nam","Russia":"Russian Federation"}
for i,country in enumerate(input_countries):
if country in change:
input_countries[i]=change[country]
countries = {}
for country in pycountry.countries:
countries[country.name] = country.alpha_3
codes = [countries.get(country, 'Unknown code') for country in input_countries]
matches_hosted['codes']=codes
matches_hosted
/var/folders/tm/2wrhck9x0kq65jq3116k2c9r0000gn/T/ipykernel_44672/2615724815.py:9: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy input_countries[i]=change[country]
| counts | country | codes | |
|---|---|---|---|
| 0 | 393 | United States | USA |
| 1 | 239 | Brazil | BRA |
| 2 | 168 | France | FRA |
| 3 | 160 | Argentina | ARG |
| 4 | 155 | Chile | CHL |
| ... | ... | ... | ... |
| 78 | 4 | Hungary | HUN |
| 79 | 3 | Egypt | EGY |
| 80 | 3 | Canada | CAN |
| 81 | 3 | Azerbaijan | AZE |
| 82 | 1 | Wales | Unknown code |
83 rows × 3 columns
#Cholorpleth of countries based on number of matches hosted
import plotly.graph_objects as go
plt.figure(figsize=(20,20))
fig = go.Figure(data=go.Choropleth(
locations = matches_hosted['codes'],
z = matches_hosted['counts'],
text = "red",
colorscale = 'reds',
autocolorscale=False,
reversescale=False,
marker_line_color='darkgray',
marker_line_width=0.5,
colorbar_title = 'Games hosted',
))
fig.update_layout(
title_text='Games hosted by Country',
geo=dict(
showframe=False,
showcoastlines=False,
projection_type='equirectangular'
),
annotations = [dict(
x=0.55,
y=0.1,
xref='paper',
yref='paper',
showarrow = False
)]
)
fig.show()
<Figure size 1440x1440 with 0 Axes>
#Tournament that has had the most games
plt.figure(figsize=(20,5))
plt.title("Tournament games count")
sns.set_style("darkgrid")
sns.barplot(x=avg_goal.index,y=avg_goal['count'],color='#d597ce');
#Goals scored by each team
home_scored=major.pivot_table(['home_score'],columns=["home_team"],aggfunc=np.sum)
home_scored=home_scored.T
away_scored=major.pivot_table(['away_score'],columns=["away_team"],aggfunc=np.sum)
away_scored=away_scored.T
home_scored=home_scored.rename(columns={"home_score":"scored"})
away_scored=away_scored.rename(columns={"away_score":"scored"})
scored_df=home_scored.append(away_scored)
scored_df=scored_df.groupby(level=0).sum()
scored_df
| scored | |
|---|---|
| Albania | 1 |
| Algeria | 106 |
| Angola | 31 |
| Argentina | 633 |
| Aruba | 8 |
| ... | ... |
| Yemen | 0 |
| Yemen DPR | 0 |
| Yugoslavia | 69 |
| Zambia | 81 |
| Zimbabwe | 13 |
160 rows × 1 columns
#Goals conceded by each team
home_conceded=major.pivot_table(['away_score'],columns=["home_team"],aggfunc=np.sum)
home_conceded=home_conceded.T
away_conceded=major.pivot_table(['home_score'],columns=["away_team"],aggfunc=np.sum)
away_conceded=away_conceded.T
home_conceded=home_conceded.rename(columns={"away_score":"conceded"})
away_conceded=away_conceded.rename(columns={"home_score":"conceded"})
conceded_df=home_conceded.append(away_conceded)
conceded_df=conceded_df.groupby(level=0).sum()
conceded_df
| conceded | |
|---|---|
| Albania | 3 |
| Algeria | 104 |
| Angola | 41 |
| Argentina | 289 |
| Aruba | 9 |
| ... | ... |
| Yemen | 10 |
| Yemen DPR | 9 |
| Yugoslavia | 68 |
| Zambia | 69 |
| Zimbabwe | 27 |
160 rows × 1 columns
# Number of games each team has played
home_games=major['home_team'].value_counts()
away_games=major['away_team'].value_counts()
games_count=home_games.append(away_games)
games_count=games_count.groupby(level=0).sum()
#Making a new table out of the data
countries_goals=pd.DataFrame(index=scored_df.index)
countries_goals['scored']=scored_df['scored']
countries_goals['conceded']=conceded_df['conceded']
countries_goals['games_played']=games_count
countries_goals['scored_avg']=countries_goals['scored']/countries_goals['games_played']
countries_goals['conceded_avg']=countries_goals['conceded']/countries_goals['games_played']
countries_goals
| scored | conceded | games_played | scored_avg | conceded_avg | |
|---|---|---|---|---|---|
| Albania | 1 | 3 | 3 | 0.333333 | 1.000000 |
| Algeria | 106 | 104 | 87 | 1.218391 | 1.195402 |
| Angola | 31 | 41 | 29 | 1.068966 | 1.413793 |
| Argentina | 633 | 289 | 293 | 2.160410 | 0.986348 |
| Aruba | 8 | 9 | 5 | 1.600000 | 1.800000 |
| ... | ... | ... | ... | ... | ... |
| Yemen | 0 | 10 | 3 | 0.000000 | 3.333333 |
| Yemen DPR | 0 | 9 | 2 | 0.000000 | 4.500000 |
| Yugoslavia | 69 | 68 | 43 | 1.604651 | 1.581395 |
| Zambia | 81 | 69 | 67 | 1.208955 | 1.029851 |
| Zimbabwe | 13 | 27 | 12 | 1.083333 | 2.250000 |
160 rows × 5 columns
#Finding who won,drew or lost from every match
home_wins_draws_loses=major[['home_team','result']]
home_wins_draws_loses.rename(columns={'home_team':'team'},inplace=True)
home_wins_draws_loses['result']=["win" if x=="home_win" else "draw" if x=="draw" else "lose" for x in home_wins_draws_loses['result']]
away_wins_draws_loses=major[['away_team','result']]
away_wins_draws_loses.rename(columns={'away_team':'team'},inplace=True)
away_wins_draws_loses['result']=["win" if x=="away_win" else "draw" if x=="draw" else "lose" for x in away_wins_draws_loses['result']]
wins_draws_loses_df=home_wins_draws_loses[['team','result']]
wins_draws_loses_df=wins_draws_loses_df.append(away_wins_draws_loses)
wins_draws_loses_df
/Users/arwasaad/opt/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py:5034: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy /Users/arwasaad/opt/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py:3607: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
| team | result | |
|---|---|---|
| 438 | Chile | lose |
| 440 | Argentina | win |
| 441 | Brazil | draw |
| 442 | Argentina | draw |
| 444 | Brazil | lose |
| ... | ... | ... |
| 42420 | Spain | draw |
| 42424 | Denmark | lose |
| 42425 | Colombia | win |
| 42426 | Argentina | win |
| 42427 | Italy | draw |
7672 rows × 2 columns
#Aggregating the counts from the above table
wins=wins_draws_loses_df.loc[(wins_draws_loses_df['result']=='win')]
wins=wins.groupby('team').count()
draws=wins_draws_loses_df.loc[(wins_draws_loses_df['result']=='draw')]
draws=draws.groupby('team').count()
loses=wins_draws_loses_df.loc[(wins_draws_loses_df['result']=='lose')]
loses=loses.groupby('team').count()
#Another option /major.pivot_table(index=['team','result'],aggfunc='count')['away_score']
#draws
wins
#loses
| result | |
|---|---|
| team | |
| Albania | 1 |
| Algeria | 31 |
| Angola | 4 |
| Argentina | 175 |
| Aruba | 1 |
| ... | ... |
| Vietnam | 2 |
| Wales | 6 |
| Yugoslavia | 16 |
| Zambia | 26 |
| Zimbabwe | 2 |
132 rows × 1 columns
countries=pd.DataFrame(index=countries_goals.index)
countries['wins']=[wins.loc[x]['result'] if x in wins.index else 0 for x in countries.index]
countries['draws']=[draws.loc[x]['result'] if x in draws.index else 0 for x in countries.index]
countries['loses']=[loses.loc[x]['result'] if x in loses.index else 0 for x in countries.index]
countries['games_played']=countries_goals['games_played']
countries['win_percentage']=((countries['wins']/countries['games_played'])*100).round(2)
countries
| wins | draws | loses | games_played | win_percentage | |
|---|---|---|---|---|---|
| Albania | 1 | 0 | 2 | 3 | 33.33 |
| Algeria | 31 | 24 | 32 | 87 | 35.63 |
| Angola | 4 | 14 | 11 | 29 | 13.79 |
| Argentina | 175 | 60 | 58 | 293 | 59.73 |
| Aruba | 1 | 1 | 3 | 5 | 20.00 |
| ... | ... | ... | ... | ... | ... |
| Yemen | 0 | 0 | 3 | 3 | 0.00 |
| Yemen DPR | 0 | 0 | 2 | 2 | 0.00 |
| Yugoslavia | 16 | 8 | 19 | 43 | 37.21 |
| Zambia | 26 | 20 | 21 | 67 | 38.81 |
| Zimbabwe | 2 | 2 | 8 | 12 | 16.67 |
160 rows × 5 columns
countries.loc['Saudi Arabia',:]
wins 27.0000 draws 16.0000 loses 33.0000 games_played 76.0000 win_percentage 35.5300 weight 0.7600 best 54.0056 Name: Saudi Arabia, dtype: float64
#Somewhat of a metric for finding best teams
countries['weight']=countries['games_played']/100
countries['best']=(2*countries['win_percentage'])*countries['weight']
countries.loc[:,['wins','games_played','win_percentage','weight','best']].sort_values('best',ascending=False).head(30)
| wins | games_played | win_percentage | weight | best | |
|---|---|---|---|---|---|
| Brazil | 212 | 347 | 61.10 | 3.47 | 424.0340 |
| Argentina | 175 | 293 | 59.73 | 2.93 | 350.0178 |
| Uruguay | 141 | 272 | 51.84 | 2.72 | 282.0096 |
| Germany | 102 | 175 | 58.29 | 1.75 | 204.0150 |
| Mexico | 102 | 210 | 48.57 | 2.10 | 203.9940 |
| United States | 81 | 149 | 54.36 | 1.49 | 161.9928 |
| Chile | 79 | 228 | 34.65 | 2.28 | 158.0040 |
| Paraguay | 72 | 206 | 34.95 | 2.06 | 143.9940 |
| Italy | 69 | 136 | 50.74 | 1.36 | 138.0128 |
| France | 64 | 119 | 53.78 | 1.19 | 127.9964 |
| Peru | 63 | 183 | 34.43 | 1.83 | 126.0138 |
| Colombia | 63 | 166 | 37.95 | 1.66 | 125.9940 |
| Costa Rica | 62 | 135 | 45.93 | 1.35 | 124.0110 |
| Nigeria | 59 | 120 | 49.17 | 1.20 | 118.0080 |
| Egypt | 58 | 113 | 51.33 | 1.13 | 116.0058 |
| Spain | 58 | 119 | 48.74 | 1.19 | 116.0012 |
| Ghana | 58 | 111 | 52.25 | 1.11 | 115.9950 |
| Cameroon | 49 | 118 | 41.53 | 1.18 | 98.0108 |
| Netherlands | 47 | 89 | 52.81 | 0.89 | 94.0018 |
| Ivory Coast | 45 | 106 | 42.45 | 1.06 | 89.9940 |
| South Korea | 44 | 111 | 39.64 | 1.11 | 88.0008 |
| England | 44 | 107 | 41.12 | 1.07 | 87.9968 |
| Iran | 43 | 83 | 51.81 | 0.83 | 86.0046 |
| Japan | 40 | 91 | 43.96 | 0.91 | 80.0072 |
| Australia | 39 | 76 | 51.32 | 0.76 | 78.0064 |
| Portugal | 36 | 74 | 48.65 | 0.74 | 72.0020 |
| Russia | 33 | 84 | 39.29 | 0.84 | 66.0072 |
| Honduras | 33 | 87 | 37.93 | 0.87 | 65.9982 |
| Belgium | 31 | 70 | 44.29 | 0.70 | 62.0060 |
| Algeria | 31 | 87 | 35.63 | 0.87 | 61.9962 |
#Just checking the tail end of the data
countries.loc[:,['wins','games_played','win_percentage','weight','best']].sort_values('best',ascending=False).tail(60)
| wins | games_played | win_percentage | weight | best | |
|---|---|---|---|---|---|
| Papua New Guinea | 3 | 14 | 21.43 | 0.14 | 6.0004 |
| Slovakia | 3 | 11 | 27.27 | 0.11 | 5.9994 |
| Norway | 3 | 11 | 27.27 | 0.11 | 5.9994 |
| Libya | 3 | 11 | 27.27 | 0.11 | 5.9994 |
| Togo | 3 | 28 | 10.71 | 0.28 | 5.9976 |
| Zimbabwe | 2 | 12 | 16.67 | 0.12 | 4.0008 |
| Burma | 2 | 4 | 50.00 | 0.04 | 4.0000 |
| Madagascar | 2 | 5 | 40.00 | 0.05 | 4.0000 |
| Iceland | 2 | 8 | 25.00 | 0.08 | 4.0000 |
| Vietnam | 2 | 9 | 22.22 | 0.09 | 3.9996 |
| German DR | 2 | 6 | 33.33 | 0.06 | 3.9996 |
| Indonesia | 2 | 13 | 15.38 | 0.13 | 3.9988 |
| Kenya | 2 | 17 | 11.76 | 0.17 | 3.9984 |
| Thailand | 2 | 24 | 8.33 | 0.24 | 3.9984 |
| Nicaragua | 2 | 35 | 5.71 | 0.35 | 3.9970 |
| Taiwan | 1 | 7 | 14.29 | 0.07 | 2.0006 |
| Cape Verde | 1 | 7 | 14.29 | 0.07 | 2.0006 |
| Malawi | 1 | 6 | 16.67 | 0.06 | 2.0004 |
| Lebanon | 1 | 6 | 16.67 | 0.06 | 2.0004 |
| Cambodia | 1 | 5 | 20.00 | 0.05 | 2.0000 |
| Kyrgyzstan | 1 | 4 | 25.00 | 0.04 | 2.0000 |
| Liberia | 1 | 5 | 20.00 | 0.05 | 2.0000 |
| Sierra Leone | 1 | 5 | 20.00 | 0.05 | 2.0000 |
| Singapore | 1 | 4 | 25.00 | 0.04 | 2.0000 |
| Aruba | 1 | 5 | 20.00 | 0.05 | 2.0000 |
| Bosnia and Herzegovina | 1 | 3 | 33.33 | 0.03 | 1.9998 |
| Albania | 1 | 3 | 33.33 | 0.03 | 1.9998 |
| Bermuda | 1 | 3 | 33.33 | 0.03 | 1.9998 |
| Slovenia | 1 | 9 | 11.11 | 0.09 | 1.9998 |
| Malaysia | 1 | 9 | 11.11 | 0.09 | 1.9998 |
| Rwanda | 1 | 3 | 33.33 | 0.03 | 1.9998 |
| Finland | 1 | 3 | 33.33 | 0.03 | 1.9998 |
| Cook Islands | 0 | 4 | 0.00 | 0.04 | 0.0000 |
| Benin | 0 | 14 | 0.00 | 0.14 | 0.0000 |
| Botswana | 0 | 3 | 0.00 | 0.03 | 0.0000 |
| Burundi | 0 | 3 | 0.00 | 0.03 | 0.0000 |
| Vietnam Republic | 0 | 6 | 0.00 | 0.06 | 0.0000 |
| Belize | 0 | 3 | 0.00 | 0.03 | 0.0000 |
| Yemen | 0 | 3 | 0.00 | 0.03 | 0.0000 |
| Yemen DPR | 0 | 2 | 0.00 | 0.02 | 0.0000 |
| Bangladesh | 0 | 4 | 0.00 | 0.04 | 0.0000 |
| Turkmenistan | 0 | 6 | 0.00 | 0.06 | 0.0000 |
| Palestine | 0 | 6 | 0.00 | 0.06 | 0.0000 |
| French Guiana | 0 | 3 | 0.00 | 0.03 | 0.0000 |
| Saint Vincent and the Grenadines | 0 | 2 | 0.00 | 0.02 | 0.0000 |
| Philippines | 0 | 3 | 0.00 | 0.03 | 0.0000 |
| Niger | 0 | 6 | 0.00 | 0.06 | 0.0000 |
| Namibia | 0 | 9 | 0.00 | 0.09 | 0.0000 |
| Mozambique | 0 | 12 | 0.00 | 0.12 | 0.0000 |
| Mauritius | 0 | 3 | 0.00 | 0.03 | 0.0000 |
| Mauritania | 0 | 3 | 0.00 | 0.03 | 0.0000 |
| Samoa | 0 | 6 | 0.00 | 0.06 | 0.0000 |
| Tanzania | 0 | 6 | 0.00 | 0.06 | 0.0000 |
| Latvia | 0 | 3 | 0.00 | 0.03 | 0.0000 |
| Suriname | 0 | 1 | 0.00 | 0.01 | 0.0000 |
| Hong Kong | 0 | 10 | 0.00 | 0.10 | 0.0000 |
| North Macedonia | 0 | 3 | 0.00 | 0.03 | 0.0000 |
| Guinea-Bissau | 0 | 6 | 0.00 | 0.06 | 0.0000 |
| Grenada | 0 | 6 | 0.00 | 0.06 | 0.0000 |
| Guyana | 0 | 3 | 0.00 | 0.03 | 0.0000 |
#Goals scored
plot_data=countries_goals.sort_values("scored",ascending=False).head(10)
plt.figure(figsize=(15,10))
plt.title("Number of Goals scored")
sns.set_style('darkgrid')
sns.barplot(x=plot_data.index,y=plot_data['scored'],color="#39375b")
<AxesSubplot:title={'center':'Number of Goals scored'}, ylabel='scored'>
#Number of goals conceded
plot_data=countries_goals.sort_values("conceded",ascending=False).head(10)
plt.figure(figsize=(15,10))
plt.title("Number of Goals conceded")
sns.set_style('darkgrid')
sns.barplot(x=plot_data.index,y=plot_data['conceded'],color="#39375b")
<AxesSubplot:title={'center':'Number of Goals conceded'}, ylabel='conceded'>
plot_data=countries.sort_values("win_percentage",ascending=False).head(10)
plt.figure(figsize=(15,10))
plt.title("Win Percentage")
sns.set_style('darkgrid')
sns.barplot(x=plot_data.index,y=plot_data['win_percentage'],color="#39375b")
<AxesSubplot:title={'center':'Win Percentage'}, ylabel='win_percentage'>
plot_data=countries.sort_values("best",ascending=False).head(10)
plt.figure(figsize=(15,10))
plt.title("Custom Best team metric")
sns.set_style('darkgrid')
sns.barplot(x=plot_data.index,y=plot_data['best'],color="#39375b")
<AxesSubplot:title={'center':'Custom Best team metric'}, ylabel='best'>